<?php

class Application_Form_GestionGroupe_AjoutMembreForm extends Zend_Form {
	
	public function init() {
		$this->setName('ajoutmembre');

		$id = new Zend_Form_Element_Hidden('id');

		$formname = new Zend_Form_Element_Hidden('formname');
		$formname->setValue('ajout');
		$this->addElement($formname);

		/*$t = new Application_Model_UsersTable();
		$u = $t->fetchAll($t->select()->order('nom'));
		$select = new Zend_Form_Element_Select('vendeur');
		foreach($u as $h) {
			if($h['mdp'] != '') {
				$select->addMultiOption($h['login'],$h['nom'].' '.$h['prenom'].' - Pwd : OUI');
			} else {
				$select->addMultiOption($h['login'],$h['nom'].' '.$h['prenom'].' - Pwd : NON');
			}
		}
		$select->setLabel('Nouveau vendeur :');
		$select->setAttrib('id','userBox')->setAttrib('size',7)->setDecorators(array('Errors','FormErrors','ViewHelper','Label'));*/
		$autocomplete = new ZendX_JQuery_Form_Element_AutoComplete('vendeur');
		$autocomplete->setFilters(array('StripTags'))
		->setJQueryParam('autoFill', true)
		->setJQueryParams(array('source' => 'searchusers', 'minLength' => 3, 'delay' => 100));

		$pwd = new Zend_Form_Element_Password('pwd');
		$pwd->setLabel('Mot de passe (au moins 6 caractères) : ')
		->addFilter('StripTags')
		->addFilter('StringTrim')
		// ->addValidator('StringLength', false, array(6))
		->setDecorators(array('ViewHelper',
				'FormErrors',
		array(array('datapwd' => 'HtmlTag'), array('tag' => 'td')),
		array('Label', array('tag' => 'td')),
		array(array('row' => 'HtmlTag'), array('tag' => 'tr')),
				'Errors'));

		$pwd_verif = new Zend_Form_Element_Password('pwd_verif');
		$pwd_verif->setLabel('Retapez le mot de passe : ')
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->setDecorators(array('ViewHelper',
				'FormErrors',
		array(array('datapwdverif' => 'HtmlTag'), array('tag' => 'td')),
		array('Label', array('tag' => 'td')),
		array(array('row' => 'HtmlTag'), array('tag' => 'tr')),
				'Errors'));

		$send = new Zend_Form_Element_Submit('send2');
		$send->setLabel('Ajouter')
		->setAttrib('class','button')
		->setDecorators(array('ViewHelper','FormErrors','Errors'));

		$cancel = new Zend_Form_Element_Reset('cancel');
		$cancel->setLabel('Annuler')
		->setAttrib('class','button')
		->setDecorators(array('ViewHelper','FormErrors','Errors'));


		$this->addElement($id)
		->addElement($formname)
		//->addElement($select)
		->addElement($autocomplete)
		->addELement($pwd)
		->addElement($pwd_verif)
		->addElement($send)
		->addElement($cancel);
	}

}